package patrol.mobile.com.mobilepatrol.activity.yanghuke.zuoyefenbu;

import android.content.Intent;
import android.graphics.Paint;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.BaseActivity;
import patrol.mobile.com.mobilepatrol.activity.yanghuke.zuoyeshangbao.GqpxActivity;
import patrol.mobile.com.mobilepatrol.activity.yanghuke.zuoyeshangbao.XcaqBfActivity;
import patrol.mobile.com.mobilepatrol.activity.yanghuke.zuoyeshangbao.ZuoyeWanchengGzLActivity;
import patrol.mobile.com.mobilepatrol.bean.DingweiBean;

public class ZuoyeFenbuDetailActivity extends BaseActivity {
    @BindView(R.id.mEditZyrq)
    TextView mEditZyrq;
    @BindView(R.id.riqiXuanzeQiLayout)
    LinearLayout riqiXuanzeQiLayout;
    @BindView(R.id.mEditTqqk)
    TextView mEditTqqk;
    @BindView(R.id.mEditLux)
    TextView mEditLux;
    @BindView(R.id.mEditZhuangh)
    TextView mEditZhuangh;
    @BindView(R.id.mEditLeib)
    TextView mEditLeib;
    @BindView(R.id.mEditRens)
    TextView mEditRens;
    @BindView(R.id.mEditJsy)
    TextView mEditJsy;
    @BindView(R.id.mEditAqy)
    TextView mEditAqy;
    @BindView(R.id.mEditDaoban)
    TextView mEditDaoban;
    @BindView(R.id.mEditweizhi)
    TextView mEditweizhi;
    @BindView(R.id.mEditneirong)
    TextView mEditneirong;
    @BindView(R.id.zuoyeDetailButton1)
    CheckBox zuoyeDetailButton1;
    @BindView(R.id.zuoyeDetailButton2)
    CheckBox zuoyeDetailButton2;
    @BindView(R.id.zuoyeDetailButton3)
    CheckBox zuoyeDetailButton3;

    private DingweiBean.ListBean listBean;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_zuoyefenqu_detail_layout;
    }

    @Override
    public void initData() {
        super.initData();
        tv_center_title.setVisibility(View.VISIBLE);
        iv_back.setVisibility(View.VISIBLE);
        tv_center_title.setText("作业信息区");

        listBean = (DingweiBean.ListBean) getIntent().getSerializableExtra("data");
        mEditZyrq.setText(listBean.getWorksDate());
        mEditTqqk.setText(listBean.getWeather());
        mEditLux.setText(listBean.getRoutelinename());
        mEditZhuangh.setText(listBean.getPot());
        mEditLeib.setText(listBean.getWorksType());
        mEditneirong.setText(listBean.getWorksInfo());
        mEditRens.setText(listBean.getWorksNum());
        mEditJsy.setText(listBean.getTechnician());
        mEditAqy.setText(listBean.getSecurity());
        mEditDaoban.setText(listBean.getWorksTeam());
        mEditweizhi.setText("经度:" + listBean.getOlat() + "  维度:" + listBean.getOlng());
        zuoyeDetailButton1.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        zuoyeDetailButton2.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        zuoyeDetailButton3.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        if (listBean.getIsPost() == 1) {
            zuoyeDetailButton1.setChecked(true);

        } else {
            zuoyeDetailButton1.setChecked(false);
        }
        if (listBean.getIsLay() == 1) {
            zuoyeDetailButton2.setChecked(true);
        } else {
            zuoyeDetailButton2.setChecked(false);
        }
        if (listBean.getIsUpQty() == 1) {
            zuoyeDetailButton3.setChecked(true);
        } else {
            zuoyeDetailButton3.setChecked(false);
        }
        zuoyeDetailButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listBean.getYhkOperationAreaPostList().size() > 0) {
                    startActivity(new Intent(v.getContext(), GqpxActivity.class)
                            .putExtra("id", listBean.getId())
                            .putExtra("yhkOperationAreaPostListBean", listBean.getYhkOperationAreaPostList().get(0)));
                } else {
                    startActivity(new Intent(v.getContext(), GqpxActivity.class).putExtra("id", listBean.getId()));
                }

                if (listBean.getIsPost() == 1) {
                    zuoyeDetailButton1.setChecked(true);
                } else {
                    zuoyeDetailButton1.setChecked(false);
                }
            }
        });
        zuoyeDetailButton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listBean.getYhkOperationAreaLayList().size() > 0) {
                    startActivity(new Intent(v.getContext(), XcaqBfActivity.class)
                            .putExtra("id", listBean.getId())
                            .putExtra("yhkOperationAreaLayListBean", listBean.getYhkOperationAreaLayList().get(0)));
                } else {
                    startActivity(new Intent(v.getContext(), XcaqBfActivity.class)
                            .putExtra("id", listBean.getId()));
                }
                if (listBean.getIsLay() == 1) {
                    zuoyeDetailButton2.setChecked(true);
                } else {
                    zuoyeDetailButton2.setChecked(false);
                }
            }
        });
        zuoyeDetailButton3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(v.getContext(), ZuoyeWanchengGzLActivity.class)
                        .putExtra("id", listBean.getId()));
                if (listBean.getIsUpQty() == 1) {
                    zuoyeDetailButton3.setChecked(true);
                } else {
                    zuoyeDetailButton3.setChecked(false);
                }
            }
        });
    }

    @Override
    public void setListener() {
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

}
